package com.mes.cloud.commons;

import java.io.Serializable;


/**
 * 键值对
 *
 * @param <TK> key-class
 * @param <TV> value-class
 */
public class KV<TK, TV> implements Serializable {

    private static final long serialVersionUID = 1L;

    private TK k;
    private TV v;

    public KV() {
    }

    public KV(TK k, TV v) {
        this.k = k;
        this.v = v;
    }

    public TK getK() {
        return k;
    }

    public KV<TK, TV> setK(TK k) {
        this.k = k;
        return this;
    }

    public TV getV() {
        return v;
    }

    public KV<TK, TV> setV(TV v) {
        this.v = v;
        return this;
    }

    public static <K, V> KV<K, V> of(K k, V v) {
        return new KV<K, V>(k, v);
    }

    @Override
    public String toString() {
        return toString(":");
    }

    public String toString(String split) {
        StringBuilder sb = new StringBuilder();
        sb.append(getK()).append(split).append(getV());
        return sb.toString();
    }
}
